﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

public partial class Admin : BasePage
{
  
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtTitle.Text = "";
        txtSummary.Text = "";
        txtContent.Text = "";
    }
    protected void btnPost_Click(object sender, EventArgs e)
    {
        PostingDAO postDAO = new PostingDAO();
        PostingInfo posting = new PostingInfo();
        if (txtTitle.Text != "")
        posting.Title = txtTitle.Text;

        if (txtSummary.Text != "")
        posting.Summary = txtSummary.Text;

        if (txtContent.Text != "")
        posting.Content = txtContent.Text;

        posting.PostingDate = DateTime.Now;

        if(Request.Cookies["culture"].Value == "en-US")
            posting.Lang = "en";
        else posting.Lang = "vi";

        if (postDAO.Insert(posting)) lblMessage.Text = "New Post is inserted sucessfully.";
        else lblMessage.Text = "Error";
    }
}